spb/wp-spboucher-ai
Public
1import type { Metadata } from "next";2import Link from "next/link";3import { notFound } from "next/navigation";4import { getLocale } from "@/lib/i18n/server";5import { href, t } from "@/lib/i18n";6import { getPaper } from "@/lib/papers/queries";7export async function generateMetadata({ params }: { params: Promise<{ id: string }> }): Promise<Metadata> { const { id } = await params; const p = await getPaper(id); return p ? { title: `${p.identifier} · ${p.title} — read`, robots: { index: false } } : {}; }8export default async function ReadPage({ params }: { params: Promise<{ id: string }> }) {9 const { id } = await params; const locale = await getLocale(); const d = t(locale); const p = await getPaper(id);10 if (!p || !p.has_pdf || !p.file_id) notFound();11 const url = `/api/files/${p.file_id}/${p.slug}-${p.version_label ?? "current"}.pdf?inline=1`;12 return (13 <div className="container py-6">14 <div className="flex flex-wrap items-center gap-3 mb-3"><Link href={href(locale, `/papers/${p.slug}`)} className="btn btn-sm no-underline">← {p.identifier}</Link><h1 className="text-lg truncate">{p.title}</h1><a href={url.replace("?inline=1", "")} className="btn btn-sm ml-auto no-underline">{d.paper.download}</a></div>15 <object data={url} type="application/pdf" className="w-full card" style={{ height: "calc(100dvh - 10rem)" }} aria-label={d.paper.readerTitle}>16 <p className="p-6 text-fg-2">{d.paper.readerFallback} <a href={url.replace("?inline=1", "")} className="text-navy">{d.paper.download}</a></p>17 </object>18 </div>19 );20}21